<?php
namespace app\index\model;
use think\Db;
class Fabulous
{
    /**
     * @param 点赞
     * @param $beiuserid
     * @return bool
     */
    static public function dianzhan($userid,$beiuserid){
        list($start,$end) = \think\helper\Time::today();
        $time = $end-time();
        if(cache($userid.'点赞'.$beiuserid)){
            return false;
        }
        $sul = Db::connect();
        $zan = $sul->name('user')->where('id',$beiuserid)->field('fabulous')->find();
        $fen = $zan['fabulous']+1;
        $bool = Db::name('user')->where('id',$beiuserid)->update(['fabulous'=>$fen]);
        if($bool){
            if(cache($userid.'点赞'.$beiuserid,'1',$time)){
                return true;
            }else{
                return false;
            }
        }else{
            return false;
        }
    }

}